<?php
namespace Plu\qdh\Controllers\Api;


use Plu\qdh\Controllers\Api\ControllerBase;
use Plu\qdh\Services\PassportService;
use Plu\qdh\Plugins\WechatCryptPlugin;
use Plu\qdh\Services\OrderService;



/**
 * @RoutePrefix("/passport")
 */
class PassportController extends ControllerBase {

    /**
	 * @Get('/createSession')
	 * 获取3rdSession
	 */
    public function createSessionAction() {
        $code  = $this->request->getQuery('code');
        $sessionInfo = $this->passport->loginWechat($code);
        return $this->release($sessionInfo);
    }

    /**
	 * @Get('/accountLogin')
	 * 微信授权登录
	 */
    public function accountLoginAction() {
        $iv         = $this->request->getQuery('iv');
        $sessionId  = $this->request->getQuery('sessionId');
        $encryptedData = $this->request->getQuery('encryptedData');
        $qdhToken   = $this->passport->wechatCrypt($encryptedData, $iv, $sessionId);
        return $this->release($qdhToken);
    }





}